package com.example.main.tab

import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import com.example.main.R
import dagger.internal.DoubleCheck
import me.majiajie.pagerbottomtabstrip.internal.RoundMessageView
import me.majiajie.pagerbottomtabstrip.item.BaseTabItem

/**
 * 普通TabView
 */
class RoundTabView @JvmOverloads constructor(context: Context, attrs:AttributeSet?=null, defaultStyle: Int=0) :BaseTabItem (context, attrs,defaultStyle){
    private lateinit var mIcon:Drawable
    private var imageView: ImageView
    init {
        //加载布局
        LayoutInflater.from(context).inflate(R.layout.tab_round_layout,this,true)
        //获取UI组件
        imageView = findViewById(R.id.tab_icon)
    }

    /**
     * 初始化数据
     */
    fun initData(@DrawableRes defaultIcon:Int){
        mIcon = ContextCompat.getDrawable(context, defaultIcon)!!
    }
    /**
     * 使用@DrawableRes， @ColorRes，@StringRes注解约束参数必须为Res下的资源
     */



    override fun setChecked(checked: Boolean) {
        imageView.setImageDrawable(mIcon)
    }

    override fun setMessageNumber(number: Int) {}

    override fun setHasMessage(hasMessage: Boolean) {}

    override fun setTitle(title: String) {}

    override fun setDefaultDrawable(drawable: Drawable) {
        imageView.setImageDrawable(drawable)
    }

    override fun setSelectedDrawable(drawable: Drawable) {
        imageView.setImageDrawable(drawable)
    }

    override fun getTitle(): String {
        return ""
    }
}